/**
 * @description 自动import导入所有 api 模块
 */

const files = require.context('./model', true, /\.js$/)
const modules = {}
files.keys().forEach((key) => {
	let t = key.replace(/(\.\/|\.js)/g, '').replace('/', '.');
	const parts = t.split('.');
	let currentObj = modules;
	for (let i = 0; i < parts.length - 1; i++) {
		const part = parts[i];

		if (!currentObj[part]) {
			currentObj[part] = {};
		}

		currentObj = currentObj[part];
	}

	currentObj[parts[parts.length - 1]] = currentObj[parts[parts.length - 1]] == null ? files(key).default : currentObj[parts[parts.length - 1]];
})

export default modules
